package com.lakeworks.processor;

import com.lakeworks.decision.PushTicketDecision;
import com.lakeworks.decision.UpdateTicketDecision;
import com.lakeworks.decision.base.Decision;
import com.lakeworks.domain.TktProcess;
import com.lakeworks.event.UpdateTicketEvent;
import com.lakeworks.processor.base.AbstractTicketProcessor;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class UpdateTicketProcessor extends AbstractTicketProcessor<UpdateTicketEvent> {

    @Override
    public TktProcess apply(
            UpdateTicketEvent event
    ) {
        var process = super.apply(event);
        process.setNodeId(process.getNodeId());
        process.setComment("工厂:【更新工单】");
        process.setTicketId(event.getTicket().getId());
        process.setRemark(event.getTicket().getRemark());
        List<Decision> list = new ArrayList<>();
        //添加向平台推送工单信息决策
        list.add(new UpdateTicketDecision(event.getTicket(),event.getOperator()));
        process.setDecisions(list);
        return process;
    }
}
